package demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:张熳
 * Date:2025-08-24
 * Time:1:18
 */
//继承
//子类构造方法 + 初始化（实例代码块、静态代码块和构造方法）

public class Test {
    public static void main(String[] args) {
        //初始化
        //先执行父类和子类的静态代码块，再执行父类的实例代码块和构造方法，最后执行子类的实例代码块和构造方法
        Dog dog = new Dog("小狗",1);
        System.out.println("============");
        Dog dog1 = new Dog("小狗",1);
    }
    public static void main1(String[] args) {
        //子类构造方法
        //Cat cat = new Cat();
        //Cat cat = new Cat("小猫",2);
        Cat cat = new Cat();
        System.out.println(cat.name+","+cat.age);
    }
}
